<?php
putenv("DISPLAY=:1");
putenv("XAUTHORITY=/var/www/.Xauthority");

ini_set('display_errors', 1);
error_reporting(E_ALL);

include_once 'Bot.php';
include_once 'Api.php';

$svn = isset($_REQUEST['svn']) ? $_REQUEST['svn'] : false;
$redmineId = isset($_REQUEST['redmine_id']) ? $_REQUEST['redmine_id'] : false;
$playform =  isset($_REQUEST['playform']) ? $_REQUEST['playform'] : false;

$result = array();

if ($svn) {
    $user = Bot::getInstance()->getUserBySvn($svn);

    if ($user) {
        $result = $user;
    }
}

if ($redmineId) {
    $user = Bot::getInstance()->getUserByIdRedmine($redmineId);

    if ($user) {
        $result = $user;
    }
}

if ($playform) {
    $user = Bot::getInstance()->getUserByPlayform($playform);

    if ($user) {
        $result = $user;
    }
}

echo json_encode($result);